var _tools = require("../../../utils/tools.js"), _tools2 = _interopRequireDefault(_tools);

function _interopRequireDefault(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

var that, app = getApp();

Page({
    data: {
        share: {
            text: "",
            xcx_title: "",
            share_image: "",
            member_id: "",
            cash_money: 0
        },
        payment_code: "",
        payment_code_url: "",
        is_cash: 1,
        audit_model: !0
    },
    onLoad: function(t) {
        that = this;
    },
    onReady: function() {
        wx.setNavigationBarColor({
            frontColor: "#000000",
            backgroundColor: "#000000"
        });
        var t = {
            action: "cash",
            contr: "my",
            token: wx.getStorageSync("token")
        };
        _tools2.default.request(t, function(t) {
            that.setData(t.info), that.setData({
                payment_code_url: that.data.member.payment_code_url,
                payment_code: that.data.member.payment_code
            });
        });
    },
    onShow: function() {},
    bindWithdrawAllClick: function() {
        this.setData({
            cash_money: this.data.member.money
        });
    },
    bindWithdrawBtnClick: function() {
        var t = parseFloat(this.data.member.money), a = parseFloat(this.data.cash_money);
        if (t < a) return wx.showToast({
            icon: "none",
            title: "余额不足"
        }), !1;
        if (1 != this.data.is_cash) return !1;
        this.data.is_cash;
        var e = {
            action: "withdrawals",
            contr: "my",
            token: wx.getStorageSync("token"),
            money: a,
            payment_code: this.data.payment_code
        };
        _tools2.default.request(e, function(t) {
            that.setData({
                is_cash: 1
            }), 2 == t.status ? wx.showModal({
                title: "提示",
                mask: !0,
                content: t.info,
                showCancel: !1
            }) : (wx.showToast({
                title: "提现成功"
            }), that.setData({
                cash_money: 0
            }), that.onReady());
        });
    },
    bindKeyInput: function(t) {
        this.data.cash_money = t.detail.value;
    },
    onHide: function() {},
    addImg: function() {
        var e = this;
        e.data.imgs && 3 <= e.data.imgs.length ? _tools2.default.showNotice("最多上传1张") : wx.chooseImage({
            count: 1,
            success: function(t) {
                var a = [];
                console.log(e.data.imgs), e.data.imgs && (a = e.data.imgs), t.tempFiles.forEach(function(t) {
                    a.push(t.path);
                }), e.setData({
                    imgs: a
                }), _tools2.default.upload(t.tempFiles[0].path, function(t) {
                    e.setData({
                        payment_code: t.info.path,
                        payment_code_url: t.info.url
                    });
                });
            }
        });
    },
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: this.data.share.text,
            imageUrl: this.data.share.images,
            path: "bh_bargain/pages/index/index?parent_id=" + this.data.share.member_id
        };
    },
    bindRecordBtn: function() {
        wx.navigateTo({
            url: "/bh_bargain/pages/moneyLog/moneyLog"
        });
    }
});